package cn.nfwx.tv.model;

import java.util.ArrayList;
import java.util.List;

public class SubscriptModel {

    /**
     * description : 央视各大频道
     * language : 普通话
     * hint : 关注时事动态，了解最新政策
     * subject_id : 1
     * subject_name : 新闻联播
     * time : 每晚七点
     * snap : http://southtv.kmdns.net:2935/logo/channel_14.jpg
     * channel : 中央一套
     */

    private String description;
    private String language;
    private String hint;
    private int subject_id;
    private String subject_name;
    private String time;
    private String snap;
    private String channel;
    private boolean isFousc;
    private List<TvProgram> programs;

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getLanguage() {
        return language;
    }

    public void setLanguage(String language) {
        this.language = language;
    }

    public String getHint() {
        return hint;
    }

    public void setHint(String hint) {
        this.hint = hint;
    }

    public int getSubject_id() {
        return subject_id;
    }

    public void setSubject_id(int subject_id) {
        this.subject_id = subject_id;
    }

    public String getSubject_name() {
        return subject_name;
    }

    public void setSubject_name(String subject_name) {
        this.subject_name = subject_name;
    }

    public String getTime() {
        return time;
    }

    public void setTime(String time) {
        this.time = time;
    }

    public String getSnap() {
        return snap;
    }

    public void setSnap(String snap) {
        this.snap = snap;
    }

    public String getChannel() {
        return channel;
    }

    public void setChannel(String channel) {
        this.channel = channel;
    }

    public List<TvProgram> getPrograms() {
        return programs;
    }

    /**
     * 获取省略的数据
     *
     * @return
     */
    public List<Object> getEllipsisList() {
        List<Object> objects = new ArrayList<>();
        objects.add(this);
        if (getPrograms() != null && !getPrograms().isEmpty()) {
            if (getPrograms().size() > 2) {
                objects.addAll(getPrograms().subList(0, 2));
                objects.add(new LoadMore(subject_id, false));
            } else {
                objects.addAll(getPrograms());
            }
        }
        return objects;
    }

    /**
     * 获取多余加载的数据
     *
     * @return
     */
    public List<Object> getMoreList() {
        List<Object> objects = new ArrayList<>();
        if (getPrograms().size() > 2) {
            objects.addAll(getAllList().subList(3, getAllList().size() - 1));
        }
        return objects;
    }

    /**
     * 获取全部数据
     *
     * @return
     */
    public List<Object> getAllList() {
        List<Object> objects = new ArrayList<>();
        objects.add(this);
        if (getPrograms() != null && !getPrograms().isEmpty()) {
            objects.addAll(getPrograms());
            objects.add(new LoadMore(subject_id, true));
        }
        return objects;
    }


    public void setPrograms(List<TvProgram> programs) {
        this.programs = programs;
    }

    public boolean isFousc() {
        return isFousc;
    }

    public void setFousc(boolean fousc) {
        isFousc = fousc;
    }

    public static class LoadMore {
        public int subject_id;
        public boolean isLoadMore;

        public LoadMore(int subject_id, boolean isLoadMore) {
            this.subject_id = subject_id;
            this.isLoadMore = isLoadMore;
        }
    }
}
